#include <bits/stdc++.h>
#define N 400005
using namespace std;
typedef long long ll;

int T;
ll pre[N], suf[N], vec[N], x[N];

set <ll> s;
set <ll>::iterator it;

int main ()
{
    freopen("kte2.in", "r", stdin);
    freopen("kte.out", "w", stdout);

    scanf("%d", &T);
    for (int t=1; t<=T; t++) { scanf("%lld", &x[t]); }
    
    for (int t=1; t<=T; t++) {
        if (s.find(x[t])!=s.end()) { s.erase(x[t]); } 
        else { s.insert(x[t]); }

        int len=0;
        for (it=s.begin(); it!=s.end(); it++) { vec[++len]=(*it); }
        pre[0]=0; for (int i=1; i<=len; i++) { pre[i]=pre[i-1]+vec[i]; }
        suf[len+1]=0; for (int i=len; i>=1; i--) { suf[i]=suf[i+1]+vec[i]; }

        ll r=0, ans=0;
        for (int i=1; i<=len; i++) {
            // [pre[i], suf[len-i+1]-1]
            ll cl=pre[i], cr=suf[len-i+1]-1;
            if (cl>cr) { continue; }
            ans+=cr-max(cl-1, r); r=max(r, cr);
        }
        printf("%lld\n", ans);
    }

    return 0;
}